<template>
  <div id="app">
    <router-link :to="{name: 'mapState'}">mapState</router-link>
    <router-link :to="{name: 'getters'}">getters</router-link>
    <router-link :to="{name: 'mutations'}">mutations</router-link>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'App',
  created() {
    if (sessionStorage.getitem("store")) {
      this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(sessionStorage.getItem('store'))));
    }
    window.addEventListener('beforeunload', function() {
      sessionStorage.setItem('store', JSON.stringify(this.$store.state))
    })
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
a {
  margin:0 10px;
}
</style>
